<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>

        /** 4
               * 功能：传入一个字符串，返回该字符串中倒数第二个位置对应的值
               * 形参：1个
               * 返回值：有，返回该字符串中倒数第二个位置对应的值
               */

        let str = 'abcdef'
        function getStr(str) {
            for (let i = 0; i < str.length; i++) {
                //str.length - 2
                zimu = str[str.length - 2]
            }
            return zimu
        }
        let re = getStr(str)
        console.log(re)



    </script>
</body>

</html>